struct Solution {}

fn main() {}

impl Solution {
    pub fn minimum_subarray_length(nums: Vec<i32>, k: i32) -> i32 {
        let mut length_vec: Vec<i32> = vec![];
        for idx in 0..nums.len() {
            let ret = Self::get_ret_start_at_idx(&nums, idx, &k);
            length_vec.push(ret);
        }

        length_vec.iter().filter(|&e| *e != -1).min().unwrap_or(&-1).to_owned()
    }

    fn get_ret_start_at_idx(nums: &Vec<i32>, idx: usize, k: &i32) -> i32 {

        let mut ret = -1;
        let mut cal = nums[idx];
        for mut end in idx..nums.len() {
            cal |= nums[end];
            if cal >= *k {
                ret = (end - idx + 1) as i32;
                break;
            }
            end += 1;
        }
        ret
    }
}